package utils

import (
	"goadmin/conf"

	"golang.org/x/crypto/bcrypt"
)

func GeneratePwdHash(pwd string) (string, error) {
	bytes, err := bcrypt.GenerateFromPassword([]byte(pwd), conf.User.PwdCost)
	return string(bytes), err
}

func VerifyPwdHash(pwd, hash string) error {
	return bcrypt.CompareHashAndPassword([]byte(hash), []byte(pwd))
}
